----------------------------------------------------------------------------------------------------------------------------------------
ReClock 1.2 by OGO (ogo@nerim.net)
Web site: http://ogo.nerim.net/reclockfilter

Please take time to test ReClock, and report success or failures to make it work with your PC. Have a look on changelog.txt and on my website for latest modifications.
----------------------------------------------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------
What is ReClock?
----------------------------------------------------------------------------------------------------------------------------------------

Said simply the purpose of ReClock is to definitely get rid (I hope) of jerky playback of AVI and MPEG material on a PC (or a PC connected to a TV).

ReClock is born from my own frustration. I have a fast PC, a good video card, and when I play a DIVX on my brand new Home Cinema, I get dropped frames here and there for no reason, or a completely jerky and un-watch able DIVX. This is very annoying. 

The following sections will give you a complete and I hope clear explanation of what cause jerky playback, and how ReClock will try to solve these problems.

The last section will give you the instructions on how to install and use ReClock.

----------------------------------------------------------------------------------------------------------------------------------------
The not so great history of frame rates
----------------------------------------------------------------------------------------------------------------------------------------

In basic terms, a video can be thought of as being made up of numerous snapshots, called frames. The frame rate, or the number of frames displayed each second

As you know there exist 3 common broadcasting formats: cinema, TV, and computers

Cinema is the oldest. It is the format of the movies you see in your favourite theater. Cinema movies play at 24 frames per second (fps). It’s very simple: every 1/24 th of a second, your see a new frame. This is also called “progressive scan”.
A television, however, does not deal with video in terms of frames. Instead, it displays video using half-frames, called fields. Each frame contains exactly two fields. One field is made up of the odd horizontal lines in a frame. This is called the odd field or the top field since it contains the top line of the image. The other field is made up of the even horizontal lines in a frame. This is called the even field or bottom field. This way to broadcast video is called “interlaced scan”
Now there are three common TV standards: PAL, SECAM and NTSC. All of them use “interlaced scan”.
Let’s start with PAL, which is the European TV standard. It is also used for DVD and DIVX material. PAL material is played at 25 fps (or 50 fields per second). You see the first problem here: how can we play a 24fps movie on a 50 fields per second PAL TV? Well first of all, we can present each movie frame two consecutive times to make the movie play at 48 fields per second. But playing the movie like this would give jerky playback every second because one movie picture would be missing. So the movie is just played 50/48 times faster to match 50 fields per second. So a cinema movie that has duration of 60mn plays on PAL in 57mn36 seconds. That’s why movies you watch on your PAL TV are always a bit shorter in time.

SECAM is the French brother of PAL and works exactly the same way. It is still used in France because it gives better colours when broadcasted by radio waves (less sensitive to noise).

And now here is NTSC, the American brother of PAL. NTSC is also used for DVD and DIVX material, and plays somewhere near 29,97 fps (to be exact it is 4,5 Mhz/286/525). You see a bigger problem here. How can we play cinema movies on NTSC. Accelerate them? Sure no, because you would notice that the film plays much too fast (a 60mn movie would play in 48mn3s). So NTSC engineers came with a solution called “telecine” or “3:2 pulldown” which is quite complicated. To convert a film that runs at 24 fps to run at 29.97 fps, it is first necessary to slow down the video by 0.1% to 23.976 fps. Then approximately 6 frames are added to the video each second, bringing the frame rate to 29.97 fps. This is done by adding one extra frame to each group of 4 film frames. Although they could simply duplicate 1 out of every 4 frames to produce the extra frame, this method is not used. This is because the duplication of one frame would cause that frame to be displayed for twice as long as the other 3 frames, which leads to jerkier motion. Fortunately, film producers can make use of the field-based nature of video to more gradually introduce the extra frame. Instead of adding a whole new frame at once, 2 fields are introduced separately to each group of 4 film frames. Since 2 fields make up a frame, this method is equivalent to adding 1 new frame. However, since the 2 duplicated fields are not added at the same time, this reduces the jerkiness of the video.

Let’s finish with computers. Computers are quite simple, they just do work like cinema and use “progressive scan”. But they use many more frame rates: 60 Hz, 75 Hz, 85 Hz, 100 Hz when watching your monitor, 50hz when connected to a PAL TV, and 60hz when connected to a NTSC TV. To obtain a smooth playback on a PC you just have to make sure that your video card uses a refresh rate that is an exact multiple of the movie you play. You can already see that PAL can be played fine at 50 Hz, 75 Hz or 100 Hz, but NTSC cannot be played without begin jerky because all we have is 60fps which is not a multiple of 29,97fps. 

----------------------------------------------------------------------------------------------------------------------------------------
The nightmare of badly born DIVX 
----------------------------------------------------------------------------------------------------------------------------------------

DIVX for the most are created from DVD material, and DVD material generally comes from movie material.

DIVX created from PAL material are generally fine, because they were created from 24 fps material simply accelerated to 25 fps or from direct 25 fps material. PAL is a good guy.

And now you have telecine for NTSC. Since telecine can only be displayed correctly on “interlaced scan” hardware, it must be removed for PC playback. This operation is called “inverse telecine”. Doing this on a film will revert the frame rate of the movie to 23,976 fps. Funny, but … jerky on every PC you will use to play the movie.

Some people that create DIVX from NTSC don’t even know that inverse telecine must be done. So those DIVX stays at 29,97fps and will have artefacts when watched on your PC because interlacing artefacts do not compress well at all. 

And to add another thing to the story, some DIVX has sound and movie sync problems that are solved by … modifying the frame rate a little bit so the movie duration matches the sound track duration. This is a quick and dirty way to do it. Imagine a 25 fps DIVX that is modified to play at 25,001 fps ; well every 1000 frames (that’s only 40 seconds) the playback will become jerky.

----------------------------------------------------------------------------------------------------------------------------------------
The bigger nightmare of PC hardware
----------------------------------------------------------------------------------------------------------------------------------------

When you connect your PAL DVD player to your TV, things are really simple. Your player read the movie from the disc at 25 fps, and sends the signal to the TV at 25 fps.
Now imagine that your player is a little too fast and send the movie to the TV at 25,01 fps. What will happen? Jerkiness? No … In fact your TV is smart, and will stay synchronised with your player as long at the player plays near 25 fps. To be more precise no player in the world plays the movie exactly at 25 fps because clocks are never accurate. So every player play the movie “near” 25 fps, but this is no problem for your TV since it is locked to the video signal it receive.

Now when you play a DIVX on your PC and watch it on your PC what happens? First of all, if the refresh rate of your monitor is not a multiple of the frame rate of your DIVX, jerkiness will happen for sure. Do you remember that DIVX can be 24 fps, 25 fps, 23,976 fps, 29,97 fps, or even 25,001 fps? This is the first and main cause of jerky playback.

The other source of jerkiness is much more subtle and harder to understand. Suppose you play a 25 fps movie on you PC. Well your PC isn’t smarter that any DVD player, it will play it “near” 25 fps because it uses its internal clock, which is inaccurate. But it should not be a problem because DVD players also do that? Bad luck, it is a very big problem, because your video card does not synchronise its speed with the speed of the movie like a TV would do with a DVD player. In a PC the clocks used in the video card (to show the video) and in the PC (to play the video) are completely distinct, thus there always is deviation between them, and then jerkiness is inevitable.

----------------------------------------------------------------------------------------------------------------------------------------
The better history of DirectShow
----------------------------------------------------------------------------------------------------------------------------------------

DirectShow is the DirectX component that plays or record video and audio on your PC. DirectShow contains many modules called “filters” and connect them in a “filter graph” to finally render the movie.
Let’s take an example, with the steps needed to play a DIVX movie:
- First you need to demux the audio and video from the AVI file: one filter will do that and will produce two streams (audio + video)
- Then you need to decode audio stream (MP3 for example): a MP3 decoder filter will do that
- You also need to decode video: a DIVX decoder filter will do that
- You must render the decoded movie in a window: a video renderer filter is needed
- You must play decoded audio: an audio renderer is used.

DirectShow was cleverly designed because it will automatically search and find what filters are the best to render a movie. For example, the audio and video renderers are completely generic (they are provided by Microsoft) and will eat the output of every decoder filter in the world.
That’s one reason why there exist many DIVX players out there. A player is only a nutshell where filter graphs are built and run.

Now, DirectShow has another interesting feature. When building a filter graph, it set up a “reference clock” that is used to provide a unique time to all the filters in the graph. All filters will play their stuff at the speed of the reference clock.
The default reference clock in DirectShow is provided by the Microsoft sound renderer. Why? Because in order to play sound correctly, your sound card must receive samples exactly at the speed they will be played. So the default reference clock is in fact synced to a hardware clock somewhere in your sound card. Video frames just follow this clock, making jerkiness inevitable.

You may ask why Microsoft made this choice. They could have chosen to sync the reference clock to the video and all would be nice. I suppose they didn’t for at least two reasons:
- Video cards do not have a high-resolution hardware timer available to make a clock.
- Sound playback would become problematic since the sound card would not receive its samples at the speed they would be played. So the sound would not stay synchronised with video

----------------------------------------------------------------------------------------------------------------------------------------
Here comes ReClock
----------------------------------------------------------------------------------------------------------------------------------------

Now I think you understand what does ReClock. It provides a reference clock that is synchronised with your video hardware. How? By replacing entirely the default sound renderer with a new rewritten DirectShow filter that is somehow cleverer.

But by doing so, ReClock must solve the two problems we saw in the last section:
- Video cards do not have a high-resolution hardware timer available to make a clock: well, this is not completely true, since many of them have something that will help us. ReClock provides a reference clock based on a high-resolution timer based on hardware on your motherboard or your processor. Let’s call this clock the “system clock”. Then, ReClock will correct the system clock with information gathered in real time from your video card if they are available. How it does that will be my little secret :)
- Sound playback would become problematic: this is true. How can we solve that? By varying the speed of the sound in real time to force the sound to stay in sync with the video. This is another reason why we replace the sound renderer with our own one. There are two ways to change sound speed: pitch and playback speed. Changing the pitch in real time is very hard to do and I was too lazy, so I went with the second solution. ReClock change the play back rate of the sound in real time by adjusting the audio clock. Doing so will change the pitch of the sound, but your ears should not notice that with such a low correction.

Another thing that does ReClock is to change the global playback rate of the movie in order to match its frame rate to a multiple of the refresh rate of your monitor. Here is how it does that:
- CINEMA mode is detected if the monitor has a refresh rate that is a multiple of 24 Hz (72 Hz, etc…) and if the movie has a frame rate between 23.75 and 24.25. Then the playback rate of the movie (including sound) is modified to match exactly 24fps.
- PAL mode is detected if CINEMA mode wasn’t possible and if the monitor has a refresh rate that is a multiple of 25 Hz (50 Hz, 75 Hz, 100 Hz, etc…) and if the movie has a frame rate between 23.75 and 25.25. Then the playback rate of the movie (including sound) is modified to match exactly 25fps.
- NTSC mode is detected if the monitor has a refresh rate that is a multiple of 30 Hz (60 Hz, 120 Hz, etc…). Then the playback rate of the movie (including sound) is modified to match exactly 30fps.
- CUSTOM mode is detected when the frame rate of the movie +/- 2% is a multiple of the monitor refresh rate. Then the playback rate of the movie (including sound) is modified to match exactly a multiple of the monitor refresh rate.
Finally if nothing matched, the playback rate is not modified, but the reference clock is still synchronised to the video card in order to obtain a stable clock. 

Side note: you may ask if NTSC will work well with TV since PC does 30fps where the TV wants 29,97fps. That’s a good question to which I do not have a complete response, but strangely I observed that when I use ReClock with the excellent TvTool in NTSC mode with a GeForce 3, I get a clock correction that make the reference clock work near … 29,97fps. So it seems that when the PC uses TV out in NTSC mode, the refresh rate is not 60 Hz, but 29,97*2 Hz, but I’m not sure at all of that, since it may be a coincidence. Anyway playing NTSC at 30 fps on a NTSC TV should not be a problem; as you may know NTSC was originally a black/white standard at 30 Hz that became 29,97 Hz for technical reasons when colour appeared.

So by adjusting the reference clock to match your video card, adjusting the sound to stay in sync with picture, and modifying the global playback rate, ReClock should allow a smooth movie experience on your monitor and even on your TV.

But as I said before, ReClock will not work with all PC because it uses some functions that are not available on all of them. Firstly your PC must support high-resolution timers (nearly every modern PC has them). Secondly, your video card must support some special calls. I know that most nVidia, ATI, Intel i815 and Matrox G200 do support those calls, but some cheaper or older cards may not. If those functions are not supported, ReClock will not load and the Microsoft audio renderer will be used.

Moreover, ReClock has some constraints you need to understand:
- ReClock requires DirectX 8.0 or higher. DirectX 9.0 or later is highly suggested.
- ReClock will load and work only if your movie has sound, because ReClock is an audio renderer.
- ReClock will not always find the frame rate of the material. For example streaming will never be supported.
- When your run ReClock for the first time for a specific resolution and refresh rate, the reference clock will be inaccurate during the first minutes of playback while being corrected. This can cause jerky playback at the beginning of the movie. The time to obtain an accurate clock will depend on many factors (initial error of clock, PC speed …). During this period, you will see a flashing yellow/red icon in the system tray. After this adjustment the icon will become green, and ReClock will store the correction in the registry, so when you will open another media, the clock correction parameters will be retrieved.
- Changing the playback speed can be noticeable on sound especially when 23,976 fps material is up rated to 25 fps. Doing so will accelerate the sound by 4%, and sound will seem to be a little high pitched.

----------------------------------------------------------------------------------------------------------------------------------------
Let’s be a little more technical
----------------------------------------------------------------------------------------------------------------------------------------
Now that you know what is DirectShow and what does ReClock, I will explain here some technical knowledge that will be useful to fully use ReClock. 

Originally, Microsoft designed one DirectShow audio renderer called the “WaveOut renderer”. This renderer was based on an old audio technology dating back to Windows 3.0 (let’s call it the Wave API). Later, when DirectX started to emerge, Microsoft designed a new audio renderer called the “DirectSound renderer” which is based on DirectSound technology (the DirectSound API). The later should provide better sound quality with less CPU overhead and less latency. On a “normal” PC with DirectX 8.0 or later, the “DirectSound renderer” is generally automatically used.

At the same time DirectSound emerged, PC started to be used to play DVD’s. As you know, nearly all DVD’s have a 5.1 Dolby or DTS soundtrack (i.e. 6 independent audio channels), that can be played on multiple speakers by your PC and the appropriate audio card, or send to an external AC3 decoder/amplifier with an SPDIF compatible soundcard. You can see those are two different ways to handle sound. When you play some media (MP3, DIVX, DVD) and your soundcard provides directly the sound to the speakers, you are using PCM (Pulse Coded Modulation) sound, and I will call this “PCM mode”. When you are sending an AC3 or DTS stream over SPDIF to an external decoder/amplifier you’re doing AC3 pass-through mode, and I will call this “SPDIF mode”.

PCM and SPDIF modes are very different by nature :
- In PCM mode, ReClock receive the raw audio waves in digital form and transmit them to the audio card, but it can tweak them because it understand what is inside.  So the sound can be reshaped (pitch or playback rate can be changed, or dynamic compression can be applied). Altering the playback rate allow ReClock to re sync the sound with the video. Playing a video at 25 fps with a sound that was “designed” to play at 24 fps is no problem.
- Now in SPDIF mode, ReClock receive a binary encoded AC3 or DTS stream and transmit it to the external decoder/amplifier via SPDIF link. But it can’t understand what is inside, because this content needs to be decoded to be understood (that’s the purpose of an AC3 decoder). So how can ReClock alter the playback rate in SPDIF ? Well, in fact it can’t do it nicely. AC3 frames are divided into chunks that have a sound duration of 32ms (a chunk is also called a frame or packet). Each frame is independent of the previous and of the next. To shorten the sound, ReClock drop frames, and to lengthen the sound, ReClock repeat frames. This is called the drop/repeat algorithm. Usually dropping or repeating an AC3 frame is not noticeable if it does not happen too often (remember a frame is only 32ms long), but it is not possible to play a media at a speed that is very far from its original speed (playing a 24 fps file at 25 fps would make a frame drop every 25 frame and it is very noticeable). That’s why in SPDIF mode, ReClock will only accept to alter the speed of media files very slightly (it won’t try to accelerate a 24 fps file to 25 fps).

Now DirectShow also have its oddities. When the “WaveOut renderer” was the only way to play sound, it was extended to handle SPDIF so it could take PCM or SPDIF input. When the “DirectSound renderer” appeared, it was plagued with problem in SPDIF handling, and many audio card manufacturers also had problems to handle SPDIF with DirectSound. So, this renderer is not commonly used to handle SPDIF. From this, you see that the best way to handle PCM sound is to use DirectSound and the best way to handle SPDIF sound is to use WaveOut. So, as ReClock needs to handle both PCM and SPDIF modes, it provides you the two worlds : WaveOut API and DirectSound API, so you have the choice. In this regard, ReClock is an hybrid audio renderer. Please have a look on a section “How to optimize SPDIF output” for a method that will allow you to minimize drop/repeats in SPDIF mode.

Let’s now speak about video renderers inside DirectShow. Just like for sound, Microsoft made with time different versions of video renderers :
- first the “Old renderer”: it uses old video technology is slow and should not be used anymore
- then the “Overlay mixer” came: this one uses “overlay” capability of video cards based on DirectDraw. Overlay is a technology that allow an application to display efficiently and with good quality pictures on screen but it has limitations : not all cards can do it, and you are limited to one video on screen (one overlay) at one time ; also overlay can cause problems when using TV output. Besides its limitations, the overlay mixer is still widely used today
- when Windows XP came out, the Video Mixing Renderer appeared, also called the “VMR7” : this one is based on Direct3D, and has no limitations. But your card must be able to handle it (recent card and recent drivers). VMR7 is used by Windows Media Player on XP.
- and finally when DirectX 9.0 appeared, a second and distinct version of the VMR came out and this one is called the “VMR9” : it is an up rated VMR7 renderer with even more capabilities. You must use a good player if you want to try this one (for example Zoom Player)
- some players like BSPlayer have their own video renderer (based on overlay for BSPlayer).

----------------------------------------------------------------------------------------------------------------------------------------
Installing and Using ReClock
----------------------------------------------------------------------------------------------------------------------------------------

Installation is straightforward; simply launch setup.exe. This will install the product in C:\Program files\ReClock by default. You will also notice a new menu in the start menu. This menu will give you access to this readme and uninstall utility.
Un-installation is simple too. Simply uninstall ReClock from the ‘add/remove program’ panel of Windows or from the ReClock menu. Do not delete ReClock folder or un register it manually, it would not uninstall it correctly! If you did something wrong to uninstall it, just reinstall and uninstall ReClock with the normal procedure and all will be well.

Now you can use the configuration application to modify some settings. You can launch it from the Start menu.
Here is an overview of the configuration application:

If you don’t know what to choose or if you messed up things, simple click on “Restore default settings”, then click on the two “Clean-up” buttons, then on OK, and all default settings and parameters will be restored.

Let’s first have a look on the “Audio settings” section. Obviously, here you will configure all sound related parameters:
- “Use DirectSound for interface PCM”: when checked use DirectSound API to play normal sounds (PCM). If unchecked, WaveOut API will be used. DirectSound is the preferred choice for PCM.
- “Use WaveOut interface for SPDIF”: when checked use WaveOut API to send AC3 over SPDIF. If unchecked, DirectSound API will be used. WaveOut is the preferred choice for SPDIF.
- “Devices to use with DirectSound/WaveOut”: You can choose here what specific soundcard must be used when using DirectSound or WaveOut. Use this if you have more than one soundcard, or if you use a specific card for SPDIF.
- “Sound pre-buffer size”: this is the amount of sound to bufferize before to play it. The lower it is, the faster you can seek inside media files. But high values also give room to handle properly sound speed variations and speed problems. Values under 100ms are not suggested.
- “Max latency for PCM/SPDIF”: You can specify here, how much sound desynchronisation is accepted on PCM or SPDIF mode between sound and video. If you experience some sound drops here and there you can try to increase the values here. Values are expressed in percentage of pre-buffer time.
- “Accept old multichannel formats”: This option was made especially for some audio cards like the Vortex2 that don’t understand special commands to handle more than 2 audio channels. If you have one of those cards, enable this option only if you get no sound at all in multichannel mode.
- “Set ReClock as preferred renderer”: if checked, ReClock will load in place of the default Microsoft DirectSound or WaveOut renderer for every media file you will play (this also apply for MP3 files played with Windows Media Player). If unchecked, you will have to configure your player to make it use ReClock. Media Player Classic and ZoomPlayer can do that (see the FAQ on my website to configure them).
- “Force ReClock to be loaded in place of default DirectSound/Wave renderers”: sometimes players explicitly ask DirectShow to play audio with a Microsoft renderer, and in this case you can’t benefit from ReClock advantages. If you check this setting, ReClock will bypass that, and be loaded even if the player requested the DirectSound or WaveOut renderer (for example Windows Media Player will play DVD with ReClock, TheaterTek DVD player too, and Windows Media Center Edition too). As you can see this is quite a dangerous setting that should only be used on a PC dedicated to media playback (like a HTPC).

Now let’s have a look on the “Video settings” section. Obviously, here you will configure all video related parameters:
- “Hardware access method”: this will give you control over which method ReClock will use to gather clock information in real time from your video card. Direct3D is the preferred method to use, but if you experience strange lockups or if ReClock doesn’t work at all, you may want to try DirectDraw which was the method used in pre 0.99k versions.
- “Video card to use”: You can specify here what video card will be used as hardware video clock source.
- “Determine frame rate of media files using DirectShow”: ReClock needs to know the frame rate of video files played in order to handle them, and DirectShow provides such mechanism. This setting don’t apply for DVD however. If you uncheck this option, ReClock will not use DirectShow to determine the frame rate. This can be useful because in very rare cases DirectShow can be inaccurate.
- “Determine frame rate of media files using built-in estimator”: This is the second way to determine frame rate (if DirectShow didn’t found it or was disabled). This setting applies only to non DVD material. If you uncheck this option, ReClock won’t try this method with media files. If this is the case, you can propose a default value in the textbox under or leave it “unknown”. Then you will be able to adjust manually the frame rate in the properties panel of ReClock during playback.
- “Determine frame rate of DVD using built-in estimator”: The same setting as the previous but only for DVD material. Now when frame rate is not found for DVD, you can propose a default value in the textbox under or leave it “unknown”. Then you will be able to adjust manually the frame rate in the properties panel of ReClock during playback.
- “Clean-up manual frame rates database”: pushing this button will erase all remembered frame rates you have ever entered in ReClock properties panel.

Now let’s have a look on the “Advanced settings” section:
- “Enable VSYNC correction with VMR9”, “Enable VSYNC correction with other renderers” : Please see paragraph “Using VSYNC Tools”
- “Give high CPU priority to player”: if enabled, higher CPU priority will be given to the player currently hosting ReClock. It is likely to give smoother playback if some background tasks are running on your PC while you watch a video.
- “Enable events notifications”: if enabled, ReClock will launch the file named “RunEvent.vbs” in the ReClock install directory, each time a media file is about to be played, or when playback condition have changed. You can customize this script to do whatever you want, for example to change the monitor refresh rate when it does not correspond to the one of the played media file. For convenience, the distribution of ReClock provides a sample called “RunEvent.sample.vbs”. For more explanations have a look inside this sample, and don’t forget to modify it properly and to rename it to “RunEvent.vbs” before to use this feature. 
- “Enable logging”: when checked enable a debug log to be produced in c:\reclock_log.txt while ReClock runs. Used only for bug tracking because it can slowdown ReClock.
- “Clean-up video clock timings database”: for each resolution, and video refresh rate, ReClock keeps track of what correction to apply to the system clock to make it match the video clock speed. For his purpose it uses an algorithm that will slowly converge to the proper correction values and then it will store those correction factors in the registry. Pushing this button will allow you to erase those correction factors in the registry. Doing so will then force ReClock to rerun the correction algorithms, for each resolution and refresh rate combination. Use this if you don’t see the “ppm” indicator going low after some time. Also it is a good idea to erase those settings, after having tweaked the video timings with Powerstrip.

Now how do you use ReClock? Simply by launching your favourite Media player (like BSPlayer, ZoomPlayer, or WMP). If all goes well, your movies should play normally and sound should be working and synced to the video.
You can see what is doing ReClock by accessing its control panel during playback. You have access to this panel from the tray icon or from the filter list in your player (it’s easy with BSPlayer and ZoomPlayer).

Speaking of the tray icon you will see it can have these colors combinations:
- Green: all is fine, ReClock found the frame rate (or it was specified manually), and is currently adapting the speed if necessary
- Flashing between Green and Red: same that Green, but ReClock has not yet found the good system clock correction to apply. Icon will go green in a few minutes, but during this playback may stay jerky.
- Yellow: ReClock cannot find a suitable speed adaptation (for example the video card refresh rate is not a multiple of the frame rate).
- Red: ReClock didn’t found the frame rate, or clock correction has been disabled

Here is an overview of the control panel:

The “Media infos” group box will give you information about the media that is currently loaded in the player. If the filename or the video stream frame rate can’t be determined, no adaptation will be made on the frame rate to match your video card refresh rate. Here you will also be able to enter frame rate manually if ReClock didn’t find it (and this will be remembered)

The “Video hardware” group box gives you information about your video card. You can see two refresh rates indicated here. The first one should be equal to the current refresh rate configured in the display properties panel of your video card. The second one will change over time and will stabilize to a value that tells you what really the refresh rate of your video card is. This one should closely match the one given by a utility like Powerstrip. Under the refresh rates, you will see the internal video clock detected by ReClock on your video card (DDR means that DirectDraw is currently used to do this job, where D3D indicates that Direct3D is used). Direct3D is the preferred method to use, but if you get lockups when playing something with ReClock, then you may want to give DirectDraw a try (all versions of ReClock prior to 0.99k were using only DirectDraw). You can configure this with the configuration application.

The “Renderers infos” group box gives you information about which video renderer you player is using for video, and what API is used for audio (either WaveOut or DirectSound).

The “Clock corrections” group box will tell you what is done by ReClock to correct the system and audio clock. The “ppm” indication gives you indications on how accurate your system clock is (the closer to 0, the best). A 1 ppm means 0.0001% of clock deviation. For example, if your clock is 3.5 Mhz, and if you play a 25 fps movie you will loose a frame every (1000000/25/3.5) second (that’s around 3 hours). For the sound part, the “sync” indicator should always be close to 0ms. You also have the ability to disable completely the system and audio clocks adaptation using the checkbox “slave reference clock to audio”. Doing so, ReClock will work much like the default DirectSound audio renderer, but rate adaptation will still function and reference clock will be slaved to audio clock with a smooth algorithm. Anyway, remember that you will probably experience jerky playback again by checking this checkbox, so the recommended way to use ReClock is to leave it unchecked.

The “Media adaptation” group box will tell you what adaptation is done to the video to match your hardware. You have the choice between different modes:
- Auto: this is the normal way to use ReClock. In this mode, ReClock will correct the speed of the media to match a multiple of your video refresh rate. If your video refresh rate does not correspond to the video, ReClock will indicate you what to do under the combo box.
- Original speed: in this mode, you can override the speed chosen by ReClock and play the media at its original speed.
- Nearest integer speed: this will round the frame rate to the nearest integer value.
- Other speeds: you can choose any target frame rate you want based on original media speed or on the refresh rate of your monitor. Audio will stay in sync (quite funny at 50 fps).
That’s being said I repeat that the best and normal way to go is to choose “Auto”.
You will also see a little check box labelled “Locked” near the media adaptation choice. If you check this button, you will force the settings used by ReClock. For example, if you have a 60 hz display, and have 24 or 25 fps media to play, you may choose “Refresh rate / 2.5” and lock it, so all media would play at 25 fps even if this is not a multiple of 60 hz.

The "Sound adaptation” group box will give you more control on sound:
- You can enable hardware resampling (by your soundcard) of sound instead of software resampling. Hardware resampling gives better sound quality (no degradation in quality at all), but due to some limitations of some soundcards, it may not work well on all soundcards (you may experience sound desynchronisation). That’s why it is not recommended.
- You can enable or disable the “dynamic range compression” for sound. This is an algorithm that will try to make the sound volume more constant.  You will see which gain is applied to sound, and how many samples were clipped (saturated). You can also choose how strong the effect of the compressor is with the combo box (light, normal, and strong). “Normal” level is suggested.

The “VSync adaptation” group box will give you control over the “VSYNC tools”. Please see the paragraph “Using VSYNC tools” for more instructions.

----------------------------------------------------------------------------------------------------------------------------------------
Using TV out with ReClock
----------------------------------------------------------------------------------------------------------------------------------------
First of all, if you have a dual head video card (a card capable to display different images on your monitor and on your TV at the same time like a Radeon for example), setup your TV as the primary display. Don’t use cloning, or theater mode. Then activate TV-out.
If your card needs a utility (like TV Tool), launch it and activate TV-out.
Then, launch your media player and open a media file, and check that the hardware video refresh rate detected by ReClock is:
 - 50 Hz if your TV is in PAL
 - 60 Hz if your TV is in NTSC
If the refresh rate detected by ReClock is not equal to the refresh rate of your TV, then either your TV is not your primary display, or ReClock is not compatible with your video card.

Important notice: if you need to adjust the size or the position of the TV image with the control panel of your video card (or TV Tool), remember to quit and restart your media player after you have made your adjustments, because ReClock will need to estimate how the hardware video clock has been affected. If you don’t do that, you will experience jerky playback. If you did something wrong, you can ask ReClock to “relearn” clock corrections by hitting the “Clean-up video timings database” in the configuration application.

As of now ReClock is known to work fine with the following cards:
- GeForce 2/3 cards with TV Tool, or with built-in drivers
- Radeon cards with built-in TV-out

If you are not sure if ReClock does correct the good video clock on your hardware, you can use the “VSYNC tools” to check that if this is the case or not. See paragraph below.

----------------------------------------------------------------------------------------------------------------------------------------
Using the VSYNC tools
----------------------------------------------------------------------------------------------------------------------------------------
ReClock is able to make sure that the video frames are rendered at a speed which is an exact multiple of the video refresh rate. But we have another problem to face: vertical synchronisation (VSYNC) versus movie frames synchronisation. The VSYNC is a signal or an impulsion that marks the start of a new frame on a TV, monitor, or projector.
Each time the video renderer draw a frame on screen it usually try to start drawing if it know it will be able to draw the entire frame during a video frame period. If it’s not the case, it will wait the next video frame (also called vertical sync or vertical blank or VSYNC), before to continue drawing. If by bad luck each frame comes near by a VSYNC, you will get permanent jerky playback because sometimes the renderer will choose to wait next VSYNC and sometimes not depending on how late the frame arrived.

ReClock tries to eliminate this problem by making sure that VSYNC will not happen at the same time as frame arrival in the renderer.
- If you want to enable VSYNC correction, you will have to check that it is enabled in the configuration application (see “Enable VSYNC correction with VMR9” and “Enable VSYNC correction with other renderers”). You have the choice to enabled it for all renderers, or all renderers but VMR9, or only with VMR9 (more on that later)
- It will activate only if the adapted media speed is an exact multiple of the hardware refresh rate (for example a 23.976 fps movie on 75 Hz TV). Since VSYNC/Frame synchronisation issues can only happen if one is an exact multiple of the other, there is no point to use the VSYNC correction when it’s not the case.

The VSYNC tools have 4 distinct purposes in ReClock:
1) They can show you on screen when does VSYNC happen. To enable this function check “Show VSYNC on screen”. You should then see on screen some points making a vertical pattern. Each point corresponds to a VSYNC that occurred during the last 100 frames played. You will also see a little horizontal line in the middle of this packet (I will call it the VSYNC bar). This is the current estimation of VSYNC position made by ReClock. Now what to learn from this? Many things:
- The height of the packet gives you an indication on how regularly frames are delivered to the renderer. If the packet height is low (10-15% of the height of your movie excluding black bars), then your playback is likely to be good.
- The position (given by the VSYNC bar) of the packet is important. There are some positions of the bar that are likely to give jerky playback because these positions correspond to instants when frames are presented to the renderer during VSYNC. Please see (3) for a solution to this
- The movements of the little VSYNC bar are very instructive. If it stay quite steady during playback (not traversing the screen completely to come back on the other side), it means that frames are presented to the renderer at a very exact multiple of the refresh rate. So it means that ReClock use the good hardware clock to make its work. This is the way to validate ReClock on multi-headed displays.

2) They can tell you if your playback is jerky or not. For this enable “Tearing test” in the properties panel. You will then see a vertical bar moving from left to right incrusted in the video. If you see the bar broken vertically somewhere, then it means that the renderer is displaying 2 frames at the same time (buffering problem). You should then choose another renderer (see your player options) or try another player. If you see the bar changing speed, or stopping/restarting, then it means your video is jerky. There can be many reasons for this
- Your CPU is not powerful enough to play the video smoothly
- Frames are presented during VSYNC. See (3) for a solution to this

3) They can tweak the reference clock to shift frame presentation in the renderer when frame come at a bad moment (during VSYNC). If you checked  “Enable VSYNC correction” in the “VSync adaptation” group box of the properties panel, or selected this in the configuration application you will enable this function. Doing so, you will see two more little horizontal bars on the left of your video. Those are the limits that are given to the VSYNC bar. Each time the VSYNC will go outside these limits, ReClock will fine tweak the reference clock to make it go back within limits. This micro-correction has no impact on the overall smoothness of the movie playing back and will ensure that you won’t get jerky playback. As said in the previous paragraphs, some VSYNC bar positions are likely to give jerky playback. From my experience, those positions depend on your system. That’s why you can choose the limits you will give to the VSYNC bar by tweaking the slider called “Target VSYNC position” in the configuration app.
Here is the procedure to find the good settings:
- Launch configuration app, check the two “Enable VSYNC Correction”, and choose left position as target for VSYNC position
- Launch your player, choose a video to playback, and enable “Tearing test”. If the test bar does not stutter, then quit your player and move the target VSYNC slider a little further on the right. Repeat this until you get a stuttering bar
- You have now found a target position that give jerky playback. Now simply move the slider one half of its size away from the current position (left or right, it’s not important), and you should be fine. For example: ¼ would become ¾, ½ would become full left or full right, etc…

However depending on the renderer filter that is used, the VSYNC correction may fight against similar algorithms implemented inside the renderer itself. Here is the situation I saw with the common renderers (but I believe it can be all different with other hardware than mine):
- VSYNC correction will be disabled with the internal renderer of BSPlayer
- Overlay mixer: does work fine
- VMR7: does works fine too
- VMR9: this renderer seems to have an internal way to do the same thing and will somehow work against the VSYNC correction algorithm of ReClock. That’s why you can disable VSYNC correction for this renderer in the configuration application if you want.
 
You may want to try the VSYNC correction with different players. The two best players I know of are ZoomPlayer and Media Player Classic as they both allow you to choose which video renderer to use.

----------------------------------------------------------------------------------------------------------------------------------------
How to optimize SPDIF output
----------------------------------------------------------------------------------------------------------------------------------------

As said before, SPDIF mode re synchronize the sound with the video part by dropping or repeating AC3 frames which can be unpleasant to the ear.
What can we do for this? First of all, try to play media files that do not need to be “reclocked” by a wide margin. For example, forcing a 24 fps file to play at 25 fps, will result in massive drop of 4% of samples which is too much and should be avoided.

Now, please follow these guidelines :
- if you want to play a file at 23,976 fps (NTSC progressive DVD) or 24 fps, put your monitor or projector at 48 hz or 72 hz, or 120 hz
- if you want to play a file at 25 fps (PAL DVD), put your monitor or projector at 50 hz or 75 hz or 100 hz
- if you want to play a file at 29,970 fps or 30 fps, put your monitor or projector at 60 hz, or 120 hz
- if you don’t fall into one of these categories, use the media adaptation called “refresh rate / x” with “x” giving the least speed difference for the file. For example if you want to play a progressive NTSC DVD (23,976 fps) on a NTSC TV (60hz), you should choose “refresh rate / 2.5” that will reclock the movie at 24 fps.

Now you have setup properly you media adaptation, there is something we can do to improve things a little bit. We can fine tune the hardware refresh rate of your video card to make it closer to the clock of you audio card, and this will minimize the number of audio drops and repeats. To do this, you need a tool called Powerstrip which is available on www.entechtaiwan.com.

The procedure is a bit tricky and should be tried by people that know what this stuff mean 

Step 1: setup your hardware properly, and choose the video refresh rate on your video card

Step 2: launch configuration application, and hit “Cleanup manual frame rates database”

Step 3: launch your favourite player and start playback of your media with AC3, set media adaptation as needed. Now wait for the ppm indicator to stabilize to a very low value (under 10 ppm)

Step 4: stop playback, and start it again for 30 minutes. After that, you can see in the properties panel a count of AC3 frames dropped or repeated. 
Now make this little computation:
E = “number of sample dropped” – “number of sample repeated”
RATE = ( (1000 x 60 x 30) + (E x 32) ) /  (1000 x 60 x 30)

Step 5: quit your player

Step 6: launch Powerstrip and go to “Display profiles” -> “Configure” -> “Advanced timing options” and check “Ultra fine geometry”. Now have a look on the refresh rate indicated by Powerstrip. Multiply this number with the RATE value you computed before, and modify it with the new value

Step 7: launch configuration application, and hit “Cleanup manual frame rates database”

Step 8: go back to step 3, and repeat the tests, until you find and optimal “refresh rate” value in Powerstrip

PS: as an alternate method, instead of recomputed each time the refresh rate with the RATE value, you can increase it by little steps if E > 0 or decrease it if E < 0.